#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll N=1e3+3,H=1e9+7;
ll n,m,ans,Fa[N],len[N],out[N],tmp[N],f[N][N];
bool fl,vis[N];
vector<int>ve[N],G[N];
void Add(ll &x,ll y){x=(x+y)%H;}
void Len(int x)
{
	len[x]=1;
	for(int y:ve[x])if(y!=Fa[x])
		Fa[y]=x,Len(y),len[x]=max(len[x],len[y]+1);
}
int Out(int x,int fa)
{
	int s=1;
	for(int y:ve[x])if(y!=fa)s=max(s,Out(y,x)+1);
	return s;
}
void Dfs(int x)
{
	cout<<"Dfs: "<<x<<" "<<len[x]<<endl; 
	for(int i=0;i<=min(len[x]-1,m);i++)f[x][i]=1;
	memset(tmp,0,sizeof(tmp));ll son=0,now=0,res=0,mk=0;
	for(int y:ve[x])if(y!=Fa[x])son++;
	for(int y:ve[x])if(y!=Fa[x])
	{
		Dfs(y);now++;mk+=len[y]>=m/2-1; 
		if(son==2&&now==2)
		{
			for(ll i=0;i<=min(len[y]-1,m-1);i++)if(out[x]+max(i+1,m-1-i)<=m)
				Add(res,f[y][i]*f[x][m-1-i]);
		}
		for(int i=1;i<=min(len[y]-1,m);i++)f[x][i]=f[x][i]*f[y][i-1]%H;
		if(m<=len[y])f[x][0]=f[x][0]*f[y][m]%H;
	}
	if(m%2==0&&mk>=2&&out[x]+m/2<=m)Add(res,f[x][m/2]);
	if(out[x]<=m)Add(res,f[x][0]);
	Add(ans,res);
	cout<<"Out: "<<x<<endl;
	for(int i=0;i<=len[x];i++)cout<<f[x][i]<<" ";
	cout<<endl;
	cout<<ans<<endl;
}
int main()
{
	freopen("life.in","r",stdin);
	//freopen("life.out","w",stdout);
	cin>>n>>m;ll res=1;
	for(int i=1,x,y;i<n;i++)cin>>x>>y,ve[x].push_back(y),ve[y].push_back(x);
	for(int i=1;i<=n;i++)
	{
		int mx1=0,mx2=0;
		for(int j:ve[i])
		{
			int d=Out(j,i);
			if(d>mx1)mx2=mx1,mx1=d;
			else if(d>mx2)mx2=d;
		}
		if(mx1+mx2+1>=m)vis[i]=1;
	}
	for(int i=1;i<=n;i++)if(!vis[i])res=res*2%H;
	for(int i=1;i<=n;i++)if(vis[i])for(int j:ve[i])if(vis[j])G[i].push_back(j);
	int rt=find(vis+1,vis+n+1,1)-vis;
	cerr<<n<<" "<<m<<" "<<count(vis+1,vis+n+1,1)<<endl;
	if(rt==n+1){cout<<res;return 0;}
	Len(rt);
	//cerr<<rt<<endl;
	for(int i=1;i<=n;i++)if(vis[i]&&i!=rt)out[i]=Out(Fa[i],i);
	Dfs(rt);
	cout<<ans*res%H<<endl;
}
